package com.recruit.g1.interestedJobs.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.recruit.g1.common.response.JsonResult;
import com.recruit.g1.interestedJobs.service.InterestedJobsService;
import com.recruit.g1.pojo.job.entity.Job;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "感兴趣岗位管理模块")
@RequestMapping("/interestedJobs")
@RestController
public class InterestedJobsController {
    @Autowired
    InterestedJobsService interestedJobsService;
    @GetMapping("/select/{userId}")
    @ApiOperation("查询感兴趣岗位")
    @ApiOperationSupport(order = 10)
    public JsonResult selectInterestedJobs(@PathVariable Long userId){
        log.debug("传过来的userID的值为{}",userId);
        List<Job> list = interestedJobsService.selectInterestedJobs(userId);
        return JsonResult.ok(list);

    }
    @GetMapping("/selectBm/{userId}")
    @ApiOperation("查询报名的工作")
    @ApiOperationSupport(order = 30)
    public JsonResult selectBmJobs(@PathVariable Long userId){
        log.debug("传过来的userID的值为{}",userId);
        List<Job> list = interestedJobsService.selectBmJobs(userId);
        return JsonResult.ok(list);

    }
    @GetMapping("/selectBm/{userId}/{jobId}")
    @ApiOperation("查询具体报名的工作")
    @ApiOperationSupport(order = 20)
    public JsonResult selectBmJob(@PathVariable Long userId,@PathVariable Long jobId){
        log.debug("传过来的userID的值为"+userId+"传过来的jobId的值为"+jobId);
        List<Job> list = interestedJobsService.selectBmJob(userId, jobId);
        return JsonResult.ok(list);

    }
    @PostMapping("/delete/{jobId}")
    @ApiOperation("取消关注感兴趣岗位")
    @ApiOperationSupport(order = 40)
    public JsonResult deleteInterestedJobs(@PathVariable Long jobId){
        interestedJobsService.deleteInterestedJobs(jobId);
        return JsonResult.ok();
    }

}
